# 字符串拼接

# 字符串拼接
def str_test1():
    # 使用+号进行拼接
    str1 = "mystr1"
    str2 = "mystr2"
    str3 = "mystr3"
    total1 = str1 + str2 + str3
    print(total1)
    # 使用 %s 进行拼接
    total2 = "this is %s %s %s" % (str1, str2, str3)
    print(total2)
    # 使用join进行字符串拼接
    # 定义一个列表
    temp = ['There are ', str1, ',',str2, ',', str3, ' on the table']
    total3 = ''.join(temp)
    print(total3)
    #  使用format进行字符串拼接
    total4 = "this is {0},{1},{2}".format(str1, str2, str3)
    print(total4)
    for i in range(0, 10):
        total5 = "this is {0},{1}".format("num"+str(i), "name"+str(i))
        print("i == ", total5)
    for i in range(10, 20):
        total6 = '''insert into `test1`(name,sex) values(%s,%s)''' % ("num"+str(i), "name"+str(i))
        print("total6 ", total6)


if __name__ == '__main__':
    str_test1()
